package com.gezi.admin.module.code.gentable.table;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gezi.admin.module.config.BaseEntity;
import com.gezi.admin.module.code.gentable.column.CodeGenTableColumnEntity;
import com.gezi.admin.module.code.gentable.table.model.CodeGenTableEditParamModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @Author 格子代码
 * @createDate 2024/2/10 09:00
 * @contact 1424529270@qq.com
 */
@Data
@TableName("code_gen_table")
public class CodeGenTableEntity extends BaseEntity {

  @ApiModelProperty(value = "表名称")
  @TableField(value = "table_name")
  private String tableName;

  @ApiModelProperty(value = "表描述")
  @TableField(value = "table_comment")
  private String tableComment;

  @ApiModelProperty(value = "使用的模板（crud单表操作 tree树表操作）")
  @TableField(value = "tpl_category")
  private String tplCategory;

  @ApiModelProperty(value = "生成包路径")
  @TableField(value = "package_name")
  private String packageName;

  @ApiModelProperty(value = "实体类名称")
  @TableField(value = "class_name")
  private String className;

  @ApiModelProperty(value = "实体类描述")
  @TableField(value = "class_remark")
  private String classRemark;

  @ApiModelProperty(value = "作者")
  @TableField(value = "author")
  private String author;

  @ApiModelProperty(value = "接口路径")
  @TableField(value = "jiekou_path")
  private String jiekouPath;

  @ApiModelProperty(value = "生成代码方式（0zip压缩包 1自定义路径）")
  @TableField(value = "gen_type")
  private String genType;

  @ApiModelProperty(value = "生成路径（不填默认项目路径）")
  @TableField(value = "gen_path")
  private String genPath;

  @ApiModelProperty(value = "其它生成选项")
  @TableField(value = "options")
  private String options;

  @ApiModelProperty(value = "备注")
  @TableField(value = "remark")
  private String remark;

  @ApiModelProperty(value = "表格是否选择")
  @TableField(value = "table_is_select")
  private Boolean tableIsSelect;

  @ApiModelProperty(value = "表格是否导入")
  @TableField(value = "table_is_import")
  private Boolean tableIsImport;

  @ApiModelProperty(value = "表格是否导出")
  @TableField(value = "table_is_export")
  private Boolean tableIsExport;

  @ApiModelProperty(value = "父级菜单id")
  @TableField(value = "parent_menu_id")
  private String parentMenuId;

  @TableField(exist = false)
  private List<CodeGenTableColumnEntity> columns;

  @TableField(exist = false)
  private CodeGenTableEntity subTable;

  public String classNameUncapitalize() {
    return org.apache.commons.lang3.StringUtils.uncapitalize(className);
  }

  public void setData(CodeGenTableEditParamModel paramModel){
    this.tableName = paramModel.getTableName();
    this.tableComment = paramModel.getTableComment();
    this.tplCategory = paramModel.getTplCategory();
    this.packageName = paramModel.getPackageName();
    this.className = paramModel.getClassName();
    this.classRemark = paramModel.getClassRemark();
    this.author = paramModel.getAuthor();
    this.jiekouPath = paramModel.getJiekouPath();
    this.genType = paramModel.getGenType();
    this.genPath = paramModel.getGenPath();
    this.options = paramModel.getOptions();
    this.remark = paramModel.getRemark();
    this.parentMenuId = paramModel.getParentMenuId();
    this.tableIsSelect = paramModel.getTableIsSelect();
    this.tableIsImport = paramModel.getTableIsImport();
    this.tableIsExport = paramModel.getTableIsExport();
  }
}